package com.dts.gateway.dto;

import com.dts.gateway.enums.ResultEnum;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * 响应实体类
 *
 * @author zhoujh
 * @date 2022/06/09 09:15
 */
@NoArgsConstructor
@AllArgsConstructor
@Data
public class ApiResult<T> implements Serializable {
    /**
     * code
     */
    private String code;

    /**
     * msg
     */
    private String message;

    /**
     * data
     */
    private T data;

    public static ApiResult call(ResultEnum resultEnum) {
        return call(resultEnum, null);
    }

    public static <T> ApiResult call(ResultEnum resultEnum, T c) {
        return new ApiResult(resultEnum.getCode(), resultEnum.getMsg(), c);
    }
}
